new Vue({
	el: '#app',
	data: {
		title: '',
		content: '',
		qid: '',
		uid: ''
	},
	mounted: function() {
		this.init();
	},
	methods: {
		init: function() {
			var self = this;
			self.uid = $api.getStorage('uid');
			apiready = function() {
				var fid = api.pageParam;
				self.qid = fid.qid;
				console.log(self.qid);
				self.getQ();
			}
			
		},
		//得到问题内容
		getQ: function() {
			var self = this;
			var data = {
				id: self.qid
			}
			$.post(base + config.sns_question_show, data, function(msg) {
				console.log(msg);
				if(msg.error == 0) {
					self.title = msg.data.title;
					self.content = msg.data.content;
				} else {
					console.log(msg.error_msg);
					api.toast({
						msg: msg.error_msg,
						duration: 2000,
						location: 'middle'
					});
				}
			}, 'json');
		},
		//修改问题
		publicQ: function() {
			var self = this;
			var data = {
				content: self.content,
				title: self.title,
				id: self.qid,
				user_id: self.uid
			}
			$.post(base + config.sns_question_update, data, function(msg) {
				console.log(msg);
				if(msg.error == 0) {
					api.openWin({
						name: 'question-details',
						url: 'questionDetails.html',
						vScrollBarEnabled: false,
						reload: true,
						pageParam: {
							qid: self.qid,
							name: 'editQuestion'
						}
					});
				} else {
					console.log(msg.error_msg);
					api.toast({
						msg: msg.error_msg,
						duration: 2000,
						location: 'middle'
					});
				}
			}, 'json');
		}
	}
})